/*
 * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
 * See LICENSE in the project root for license information.
 */

/* global document, Office */

Office.onReady((info) => {
  if (info.host === Office.HostType.Outlook) {
    document.getElementById("sideload-msg").style.display = "none";
    document.getElementById("app-body").style.display = "flex";
    document.getElementById("run").onclick = run;
  }
});
export async function run() {
  /**
   * Insert your Outlook code here
   */
  // Get a reference to the current message
  var item = Office.context.mailbox.item;
  // Write message property value to the task pane
  document.getElementById("item-subject").innerHTML = "<b>主题内容:</b> " + item.subject;
  document.getElementById("item-sender").innerHTML = "<b>发件人:</b> " + item.from.emailAddress;
  document.getElementById("item-to").innerHTML = "<b>收件人:</b> " + item.to[0].emailAddress;
  Office.context.mailbox.item.body.getAsync(
    "text",
    { asyncContext: "This is passed to the callback" },
    function callback(result) {
      // Do something with the result.
      document.getElementById("item-main").innerHTML = "<b>内容:</b> " + result.value;
    }
  );
  Office.context.mailbox.item.body.getAsync(
    "text",
    { asyncContext: "This is passed to the callback" },
    function callback(result) {
      // Do something with the result.
      console.log(result);
    }
  );
}
